$(document).ready(function () {

    $("#Register_telephone").blur(function () {
        const Register_telephone = $("#Register_telephone").val();
        if (isTelephone(Register_telephone)) {
            $("#tips").text("手机号格式正确").css("color", "#1E9FFF");
        } else {
            $("#tips").text("请输入正确的手机号格式").css("color", "#FF5722");
        }
    });
});

function Login() {
    const name = $("#telephone").val();
    const pwd = $("#login_Password").val();
    if (IsEmpty(name, pwd)) {
        layer.msg("禁止留空", {icon: 5});
        return;
    }
    $.post("/ShenBlue/LoginUser", {name: name, password: pwd}, function (data) {
        const error = data["error"];
        const msg = data["msg"];
        if (error !== undefined) {
            layer.msg(error, {icon: 5});
            setTimeout("location.reload()", 1500);
            return;
        }
        layer.msg(msg, {icon: 1});
        setTimeout("location.reload()", 1500);
        return;
    });
}

function Register() {
    const tel = $("#Register_telephone").val();
    const pwd = $("#Register_Password").val();
    const repwd = $("#Register_confirmPassword").val();
    const Safe = $("#Register_SafeValue").val();
    if (IsEmpty(tel, pwd, repwd, Safe)) {
        layer.msg("禁止留空", {icon: 5});
        return;
    }
    if (!isTelephone(tel)) {
        layer.msg("请输入正确的手机号格式", {icon: 5});
        return;
    }
    if (pwd != repwd) {
        layer.msg("请确认密码是否正确", {icon: 5});
        return;
    }
    $.post("/ShenBlue/RegisterUser", {telephone: tel, password: pwd, SafeValue: Safe}, function (data) {
        const error = data["error"];
        const msg = data["msg"];
        if (error !== undefined) {
            layer.msg(error, {icon: 5});
            setTimeout("location.reload()", 1500);
            return;
        }
        layer.msg(msg, {icon: 1});
        setTimeout("location.reload()", 1500);
        return;
    });
}

function forget() {
    const tel = $("#forget_telephone").val();
    const pwd = $("#forget_Password").val();
    const repwd = $("#forget_confirmPassword").val();
    const Safe = $("#forget_SafeValue").val();
    if (IsEmpty(tel, pwd, repwd, Safe)) {
        layer.msg("禁止留空", {icon: 5});
        return;
    }
    if (pwd != repwd) {
        layer.msg("请确认密码是否正确", {icon: 5});
        return;
    }
    $.post("/ShenBlue/ForGetUser", {telephone: tel, password: pwd, SafeValue: Safe}, function (data) {
        const error = data["error"];
        const msg = data["msg"];
        if (error !== undefined) {
            layer.msg(error, {icon: 5});
            setTimeout("location.reload()", 1500);
            return;
        }
        layer.msg(msg, {icon: 1});
        setTimeout("location.reload()", 1500);
        return;
    });
}